<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>签到签退信息查询表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />

    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>

</head>

<body onload="loadData()">
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>信息查询</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <div class="col-md-2">
                名字：<input type="text" id="name" class="form-control layui-input" autocomplete="off">
                部门：<input type="text" id="depa" class="form-control layui-input" autocomplete="off">
                <input type="button" id="buttons-hbox1" class="layui-btn" onclick="loadData()" value="查询">
            </div>
        </form>
    </div>

    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>员工编号</th>
            <th>用户名</th>
            <th>部门</th>
            <th>职位</th>
            <th>电话</th>
            <th>迟到时间</th>
            <th>迟到</th>
            <th>早退时间</th>
            <th>早退</th>


        </thead>
        <tbody id="tb">

        <tr>
            <td>
                <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
            </td>

        </tr>
        </tbody>
    </table>
    <div>
        <button type="button" class="btn btn-success btn-sm" onclick="pres()">上一页</button>
        <button type="button" class="btn btn-success btn-sm" onclick="nexts()">下一页</button>
        一共有<span id="total"></span>数据，共有<span id="totalPage"></span>页
    </div>

</div>
<script>
    //默认页面是第一页
    var page=1;
    var row = 5;
    var totalPage=0;

    var colName="depa";
    var order ="asc"
    //上一页
    function pres() {
        page--;
        if(page < 1){
            page = 1;
        }
        loadData();
    }

    //下一页
    function nexts() {
        page++;
        if(page > totalPage){
            page = totalPage;
        }

        loadData();

    }
    //加载数据
    function loadData() {
        var name = $("#name").val();
        var depa = $("#depa").val();
        var eNumber = $("#eNumber").val();
        console.log("name="+name);
        console.log("name="+depa);
        console.log("eNumber="+eNumber);

        $.ajax({
            url :"${pageContext.request.contextPath}/ess/selectBy01",
            type:"get",
            data:{"name":name,"depa":depa,"eNumber":eNumber,"page":page,"row":row,"colName":colName,"order":order},
            dataType:"json",
            success:function (data) {
                console.log(data);
                console.log(typeof(data.info));
                if(typeof(data.info)=='string'){
                    alert(data.info);
                    //清空
                    $("#tb").html(data.info);
                }else{
                    //取出总页数
                    totalPage = data.totalPage;
                    //显示总条数
                    $("#total").text(data.total);
                    //显示总页数
                    $("#totalPage").text(totalPage);

                    var html = "";
                    for(var i=0;i<data.info.length;i++){
                        html += "<tr>" +"<td>"+
                            "<td>"+data.info[i].eNumber+"</td>" +
                            "<td>"+data.info[i].name+"</td>" +
                            "<td>"+data.info[i].depa+"</td>" +
                            "<td>"+data.info[i].job+"</td>" +
                            "<td>"+data.info[i].phone+"</td>" +
                            "<td>"+data.info[i].list1[0].time+"</td>" +
                            "<td>"+data.info[i].list1[0].state+"</td>" +
                            "<td>"+data.info[i].list2[0].time1+"</td>" +
                            "<td>"+data.info[i].list2[0].state1+"</td>" +
                            "</tr>";
                    }

                    $("#tb").html(html);
                }


            }
        })
    }


</script>

</body>

</html>